﻿{extend name='public/base' /}

{block name='seo' /}
<title>{$title|default='标题'}</title>
<meta name="keywords" content="{$keywords|default='关键字'}">
<meta name="description" content="{$desc|default='描述'}">
{/block}


{block name='content' /}
<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>
		管理员菜单
		<span class="c-gray en">&gt;</span>
		日期列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a> </nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<!--如果是admin显示用户数量,其它用户没必要显示-->
			{eq name="$Think.session.user_info.username" value="admin"}
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
					<span>年度：&nbsp;
						<select name="year" id="year">
							<option value="">选择年份</option>
							{for start='2010' end='date("Y")+2' comparsion='lt' name='i' step='1'}
								{if condition="$i == date('Y')"}
									<option value="{$i}" selected="selected">{$i}</option>
								{else /}
									<option value="{$i}">{$i}</option>
								{/if}
							{/for}
						</select>
					</span>
					<span>月份：&nbsp;
						<select name="month" id="month">
							<option value="">选择月份</option>
							{for start='1' end='12' comparsion='lt' name='i' step='1'}
								{if condition="$i == date('m')"}
									<option value="{$i}" selected="selected">{$i}</option>
								{else /}
									<option value="{$i}">{$i}</option>
								{/if}
							{/for}
						</select>
					</span>
					<a href="javascript:;" onclick="date_del()" class="btn btn-danger radius">
						<i class="Hui-iconfont">&#xe6e2;</i> 删除日期数据</a>
					<span>选定年月划分为几周：&nbsp;
						<select name="week" id="week">
							<option value="">划分周度：</option>
<!-- 							<option value="1">01</option>
							<option value="2">02</option> -->
							<option value="3">03</option>
							<option value="4">04</option>
							<option value="5">05</option>
						</select>
					</span>
					<a href="javascript:;" onclick="admin_add()" class="btn btn-primary radius">
					<i class="Hui-iconfont">&#xe600;</i> 添加日期数据</a>
				</span>
				<span class="r">共有数据：<strong>{$count}</strong> 条</span>
			</div>
			{/eq}

			<table class="table table-border table-bordered table-bg">
				<thead>
					<tr>
						<th scope="col" colspan="9">信息列表</th>
					</tr>
					<tr class="text-c">
						<th width="40">ID</th>
						<th width="80">年份</th>
						<th width="80">月份</th>
						<th width="80">周度</th>
						<th width="130">单周自然日</th>
						<th width="130">累计自然日</th>
						<th width="130">单周工作日</th>
						<th width="130">累计工作日</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody>
				
				{volist name="list" id="vo"}
					<tr class="text-c">
						<td>{$vo.date_id}</td>
						<td>{$vo.yy}</td>
						<td>{$vo.mm}</td>
						<td>{$vo.ww}</td>
						<td>{$vo.day}</td>
						<td>{$vo.dayacc}</td>
						<td>{$vo.wkday}</td>
						<td>{$vo.wkdayacc}</td>
						<td class="td-manage">
							<!--切换启用与禁用图标-->
							<!--只允许admin有权启用或停用-->
							
							<a title="编辑" href="javascript:;" onclick="admin_edit('管理员编辑','{:url("user/adminEdit",["id"=>$vo.date_id])}','1','800','500')" class="ml-5" style="text-decoration:none">
								<i class="Hui-iconfont">&#xe6df;</i>
							</a>

							<!--只允许admin有删除权限-->
							{eq name="$Think.session.user_info.username" value="admin"}
							<a title="删除" href="javascript:;" onclick="admin_del(this,{$vo.date_id})" class="ml-5" style="text-decoration:none">
								<i class="Hui-iconfont">&#xe6e2;</i>
							</a>
							{/eq}


						</td>
					</tr>
				{/volist}

				</tbody>
			</table>
		</article>
	</div>
</section>
{/block}


{block name='js'}
<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript" src="__STATIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="__STATIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__STATIC__/lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript">
/*
	参数解释：
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/
/*管理员-增加*/
$(document).ready(function(){
	$('#menu-article dt').attr('class','selected');
	$('#menu-article dd').attr('style','display: block;');
});

function admin_add(){
	var yy = $("#year").val();
	var mm = $("#month").val();
	var ww = $("#week").val();
	
	var title = '添加日期';
	var w = 1000;
	var h = 500;
	if (ww == '') {
		alert('周度数据不能为空');
	}else{
		url = './dateAdd/yy/' + yy + '/mm/' + mm + '/ww/' + ww;
		// alert(url);
		$.post(url);
		layer_show(title,url,w,h);
	}
	
}


/*管理员-删除*/
function admin_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		// $.get("{:url('user/deleteUser')}",{id:id});
		
		$(obj).parents("tr").remove();
		layer.msg('已删除!',{icon:1,time:1000});
	});
}
/*管理员-编辑*/
function admin_edit(title,url,id,w,h){
    $.get(url,{id:id}); //执行控制器中的编辑操作
	layer_show(title,url,w,h);
}

function date_del(){
	var yy = $("#year").val();
	var mm = $("#month").val();

	layer.confirm('确认要恢复吗？', function () {
		url = './dateDel/yy/' + yy + '/mm/' + mm;
		$.post(url);
        
        layer.msg('已删除!', {icon: 1, time: 1000}); //消息弹层1秒后消失
        window.location.reload(); //重新加载页面,显示所有数据
    });
}


</script> 
<!--/请在上方写此页面业务相关的脚本-->
{/block}

</body>
</html>